class Sales::ProductsController < ApplicationController
  layout "sale"
  # before_action :customer_required, except: [:index, :show]
  before_action :set_store, :set_normal_store_id, :set_store_id
  before_action :set_product, only: [:show]

  def index
    # @products = @store.products.showable
    @product_categories = @store.product_categories
  end

  def show
  end

  def search
    @products = @store.products.joins(:store_product_category).uncustoms.showable.by_name(params[:name])
    @search_name = params[:name]
  end


  private
  def set_store
    @store = Store.find(params[:store_id])
  end

  def set_normal_store_id
    @normal_store_id = params[:store_id]
  end

  def set_product
    @product = StoreProduct.find(params[:id])
  end

  def set_store_id
    @store_id = encode(params[:store_id])
  end
end
